﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Camc.Duct.Migrations
{
    public partial class adfada : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "NodeBaseId",
                table: "LineInstanceExecuteHistorys");

            migrationBuilder.AddColumn<int>(
                name: "OrderIndex",
                table: "LineInstanceExecuteHistorys",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.CreateTable(
                name: "RequestBase",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    RequesterId = table.Column<string>(nullable: true),
                    RequestInfo = table.Column<string>(nullable: true),
                    Responder = table.Column<string>(nullable: true),
                    RespondTime = table.Column<DateTime>(nullable: false),
                    RespondInfo = table.Column<string>(nullable: true),
                    RespondOperation = table.Column<string>(nullable: true),
                    LineInstanceId = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RequestBase", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RequestBase_LineInstances_LineInstanceId",
                        column: x => x.LineInstanceId,
                        principalTable: "LineInstances",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_RequestBase_LineInstanceId",
                table: "RequestBase",
                column: "LineInstanceId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "RequestBase");

            migrationBuilder.DropColumn(
                name: "OrderIndex",
                table: "LineInstanceExecuteHistorys");

            migrationBuilder.AddColumn<long>(
                name: "NodeBaseId",
                table: "LineInstanceExecuteHistorys",
                nullable: false,
                defaultValue: 0L);
        }
    }
}
